import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { CategoriesModule } from './categories/categories.module';
import { UsersModule } from './users/users.module';
import { BooksModule } from './books/books.module';
import { OrdersModule } from './orders/orders.module';
import { CommonModule } from '@libs/common';
import { AdminController } from './admin.controller';
import { LocalStrategy } from './local.strategy';
import { PassportModule } from '@nestjs/passport';
import { ServeStaticModule } from '@nestjs/serve-static';
import { JwtStrategy } from './jwt.strategy';

@Module({
  imports: [
    CommonModule,
    UsersModule,
    CategoriesModule,
    BooksModule,
    OrdersModule,
    PassportModule,
    ServeStaticModule.forRoot({
      rootPath: 'static/admin',
    }),
    JwtModule.registerAsync({
      useFactory() {
        return {
          secret: process.env.SECRET,
          signOptions: {
            expiresIn: '1h',
          },
        };
      },
    }),
  ],
  controllers: [AdminController],
  providers: [LocalStrategy, JwtStrategy],
})
export class AdminModule {}
